package programer.interviewer;

public class Question2 {

    public boolean CheckPermutation(String s1, String s2) {
        if(s1.length() != s2.length()) {
            return false;
        }

        int[] bitmapS1 = new int[26];
        int[] bitmapS2 = new int[26];

        for(int i = 0; i < s1.length(); i++) {
            int value = s1.charAt(i) - 'a';
            bitmapS1[value] ++;
            value = s2.charAt(i) - 'a';
            bitmapS2[value] ++;
        }

        for(int i =0 ;i < 26; i++) {
            System.out.println(" compare:" + i + " s1:" + bitmapS1[i] + " s2:" + bitmapS2[i]);
            if(bitmapS1[i] != bitmapS2[i]) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
       boolean isUnique =  new Question2().CheckPermutation("cuhv", "cuvs");
       System.out.println(" CheckPermutation:" + isUnique);
    }
}
